package com.hafu.service;

import com.hafu.dao.TeacherDao;
import com.hafu.model.Teacher;

import java.util.ArrayList;
import java.util.List;

// 教师服务类
public class TeacherService {
    private TeacherDao teacherDao = new TeacherDao();

    public String getTeacherName(String teacherId) {
        Teacher teacher = teacherDao.getTeacherById(teacherId);
        return teacher != null ? teacher.getName() : null;
    }

    public boolean deleteTeacher(String teacherId) {
        return teacherDao.deleteTeacher(teacherId);
    }

    public List<Teacher> getAllTeachers() {
        List<Teacher> teachers = teacherDao.getAllTeachers();
        return teachers != null ? teachers : new ArrayList<>(); // 确保返回空列表
    }

    public List<Teacher> searchTeachers(String keyword) {
        List<Teacher> teachers = teacherDao.searchTeachers(keyword);
        return teachers != null ? teachers : new ArrayList<>(); // 确保返回空列表
    }

    public Teacher getTeacherById(String teacherId) {
        return teacherDao.getTeacherById(teacherId);
    }
}